package org.chengyi.model_shop.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.chengyi.model_shop.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping
public class LoginController {

    @Autowired
    private LoginService loginService;


    /**
     * 登录
     * @param username 用户名
     * @param password 密码
     * @return 登录结果
     */
    @PostMapping("/login")
    public Map<String, Object> login(@RequestParam String username, @RequestParam String password, HttpServletRequest request) {
        return loginService.login(username, password, request);
    }
    @PostMapping("/register")
    public Map<String, Object> register(@RequestParam String username,
                                        @RequestParam String email,
                                        @RequestParam String password,
                                        @RequestParam String confirmPassword) {
        return loginService.register(username,email, password,confirmPassword);
    }
}